package com.wutma.common.core.domain;

import com.wutma.common.core.enums.ResultCode;
import lombok.Data;

@Data
public class Result {

    // 消息状态码
    private int code;
    // 消息内容
    private String msg;
    // 返回数据
    private Object data;

    /**
     * 业务执⾏成功时返回的⽅法
     * @param data
     * @return
     */
    public static Result success(Object data) {

        Result result = new Result();
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMsg(ResultCode.SUCCESS.getMsg());
        result.setData(data);
        return result;
    }
    /**
     * 业务执⾏失败时返回的⽅法
     *
     * @param
     * @return
     */
    public static Result fail(int code, String msg) {
        Result result = new Result();
        result.setCode(code);        result.setMsg(msg); // 这里的msg为报错原因
        result.setData("");
        return result;
    }

}
